.\"   $Id: namealloc.3,v 1.1 2002/03/08 13:51:03 fred Exp $
.\" @(#)namealloc.2 2.11 91/08/22 ; Labo masi cao-vlsi; Author : Frederic Petrot
.if t \{\
.so man1/alc_contents.mac
.XS \n%
.ti 0.2i
namealloc
.XE
.XS4 \n%
.ti 0.2i
namealloc
.XE4 \}
.TH NAMEALLOC 3 "October 1, 1997" "ASIM/LIP6" "MBK UTILITY FUNCTIONS"
.SH NAME
namealloc \- hash table for strings
.so man1/alc_origin.1
.SH SYNOPSIS
.nf
.if n \{\
.ft B \}
.if t \{\
.ft CR \}
#include "mut.h"
char \(**namealloc(inputname)
char \(**inputname;
.ft R
.fi
.SH PARAMETER
.TP 20
\fIinputname\fP
Pointer to a string of characters
.SH DESCRIPTION
The \fBnamealloc\fP function creates a dictionary of names in mbk.
It warranties equality on characters string if the pointers to these
strings are equal, at \fBstrcmp\fP(3) meaning. This means also that there
is a single memory address for a given string.
.br
The case of the letters do not matter. All names are changed to lower case
before being introduced in the symbol table. This is needed because most
of the file format do not check case.
.br
\fBnamealloc\fP is used by all mbk utility function using names, so its use
should be needed only when directly filling or modifying the structure, or when
having to compare an external string to mbk internal ones. This should speed
up string comparisons.
.br
One shall never modify the contains of a string pointed to by a result of
\fBnamealloc\fP, since all the field that points to this name would have
there values modified, and that there is no chance that the new hash code
will be the same as the old one, so pointer comparison would be
meaningless. All string used by \fBnamealloc\fP are constants string, and
therefore must be left alone.
.SH RETURN VALUE
\fBnamealloc\fP returns a string pointer.
If the \fIinputname\fP is already in the hash table, then its internal pointer
is returned, else a new entry is created, and then the new pointer returned.
.SH EXAMPLE
.ta 3n 6n 9n 12n 15n 18n 21n
.nf
.if n \{\
.ft B \}
.if t \{\
.ft CR \}
#include "mut.h"
#include "mlo.h"
lofig_list \(**find_fig(name)
char \(**name;
{
lofig_list \(**p;
	name = namealloc(name);
	for (p = HEAD_LOFIG; p; p = p\->NEXT)
		if (p\->NAME == name) /\(** pointer equality \(**/
			return p;
	return NULL;
}
.ft R
.fi
.SH DIAGNOSTICS
\fBnamealloc\fP can be used only after a call to \fBmbkenv\fP(3).
.SH SEE ALSO
.BR mbk (1).


.so man1/alc_bug_report.1

